package src.main.java.org.string;

import java.util.Scanner;

public class StringDemo3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 1;
        System.out.println("---欢迎进入系统---");
        while (count<=3) {
            System.out.println("请输入用户名：");
            String loginName = sc.nextLine();
            System.out.println("请输入密码：");
            String passWord = sc.nextLine();
            boolean verify = verify(loginName, passWord);
            if(verify){
                System.out.println("恭喜您登陆成功");
                break;
            }else{
                if(count<=3){
                    count++;
                    continue;
                }else{
                    System.out.println("您的尝试次数已用完！");
                }

            }
        }


    }
    public  static boolean verify(String loginName,String passWord){
        String realLoginName = "itheima";
        String realPassWord = "123456";
        if(loginName.equals(realLoginName)){
            if(passWord.equals(realPassWord)){
                System.out.println("欢迎进入系统");
                return true;
            }else{
                System.out.println("登录密码错误");
                return false;
            }
        }else{
            System.out.println("用户名错误");
            return false;
        }
    }
}
